- /* sdfsinhs.cpp by K.Tsuru */
- // function ID 3308 DRADIX
- /****************************************
- SDouble class
- sinh x by series |x| < DRADIX.
- sinh x = x/1! + x^3/3! + x^5/5! + .....
- *****************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- static const char* func = "SinhSeries";
- SDouble SinhSeries(const SDouble& x){
- if(x.NetRdxExp() > 1) x.SetError(x.OUT_OF_RANGE, func, 3308);
-
- SDouble sum(x), xsq, t, delta;
- sum.FixedPoint(sum.RdxExp());
- xsq = x*x;
- t = x*xsq;
- delta = DsDiv(t, 6); // delta = x^3/6
- ulong n = 4uL, mt = sum.SlOpMaxValue(), den;
- sum = DDAdd(sum, delta); // sum += delta;
-
- while( delta.Sign(3308) ){
- den = n*(n+1uL);
- if(den >= mt) break;
- t = delta*xsq;
- delta = DsDiv(t, den); //It can devide by n(n+1) once.
- sum = DDAdd(sum, delta); // sum += delta;
- n += 2uL;
- }
-
- while(delta.Sign(3308)){
- if(n >= mt){
- sum.SetError(sum.NOT_CONVERGE, func, -3308);
- break;
- }
- t = delta*xsq;
- delta = DsDiv(t, n); delta = DsDiv(delta, n+1uL); //twice
- sum = DDAdd(sum, delta); // sum += delta;
- n += 2;
- }
- sum.PointFree();
- sum.Reform(3308);
- sum.upToTerm = n/2;
- return sum;
- }
sdfsinhs.cpp : last modifiled at 2015/12/04 10:31:02(1,185 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).